using System;
using Ext;
using Ext.data;
using ScriptFX;

namespace SampleScripts.grid {
    public class TotalsGridScript {
        public static void main(Dictionary args) {
            ExtClass.onReady(new AnonymousDelegate(delegate() { new TotalsGridScript().init(); }));
        }

        public void init() {

            JsonReader reader = new JsonReader(new JsonReaderConfig()
                .custom("idProperty", "taskId")
                .custom("fields", new Dictionary[] {
                    new Dictionary("name", "projectId", "type", "int"),
                    new Dictionary("name", "project", "type", "string"),
                    new Dictionary("name", "taskId", "type", "int"),
                    new Dictionary("name", "description", "type", "string"),
                    new Dictionary("name", "estimate", "type", "float"),
                    new Dictionary("name", "rate", "type", "float"),
                    new Dictionary("name", "cost", "type", "float"),
                    new Dictionary("name", "due", "type", "date", "dateFormat", "m/d/Y")
                })
                .ToDictionary()
            );
            
        }

        private Dictionary[] getData() {
            return new Dictionary[] {
                new Dictionary("projectId", 100, "project", "Ext Forms: Field Anchoring"),
                new Dictionary("projectId", 101, "project", "Ext Grid: Single-level Grouping"),
                new Dictionary("projectId", 102, "project", "Ext Grid: Summary Rows")
            };
        }
        private Dictionary[] getProjects() {
            return new Dictionary[] {
                new Dictionary("projectId", 100, "project", "Ext Forms: Field Anchoring", "taskId", 112, "description", "Integrate 2.0 Forms with 2.0 Layouts", "estimate", 6, "rate", 150, "due", "06/24/2007"),
                new Dictionary("projectId", 100, "project", "Ext Forms: Field Anchoring", "taskId", 113, "description", "Implement AnchorLayout", "estimate", 4, "rate", 150, "due", "06/25/2007"),
                new Dictionary("projectId", 100, "project", "Ext Forms: Field Anchoring", "taskId", 114, "description", "Add support for multiple types of anchors", "estimate", 4, "rate", 150, "due", "06/27/2007"),
                new Dictionary("projectId", 100, "project", "Ext Forms: Field Anchoring", "taskId", 115, "description", "Testing and debugging", "estimate", 8, "rate", 0, "due", "06/29/2007"),
                new Dictionary("projectId", 101, "project", "Ext Grid: Single-level Grouping", "taskId", 101, "description", "Add required rendering \"hooks\" to GridView", "estimate", 6, "rate", 100, "due", "07/01/2007"),
                new Dictionary("projectId", 101, "project", "Ext Grid: Single-level Grouping", "taskId", 102, "description", "Extend GridView and override rendering functions", "estimate", 6, "rate", 100, "due", "07/03/2007"),
                new Dictionary("projectId", 101, "project", "Ext Grid: Single-level Grouping", "taskId", 103, "description", "Extend Store with grouping functionality", "estimate", 4, "rate", 100, "due", "07/04/2007"),
                new Dictionary("projectId", 101, "project", "Ext Grid: Single-level Grouping", "taskId", 121, "description", "Default CSS Styling", "estimate", 2, "rate", 100, "due", "07/05/2007"),
                new Dictionary("projectId", 101, "project", "Ext Grid: Single-level Grouping", "taskId", 104, "description", "Testing and debugging", "estimate", 6, "rate", 100, "due", "07/06/2007"),
                new Dictionary("projectId", 102, "project", "Ext Grid: Summary Rows", "taskId", 105, "description", "Ext Grid plugin integration", "estimate", 4, "rate", 125, "due", "07/01/2007"),
                new Dictionary("projectId", 102, "project", "Ext Grid: Summary Rows", "taskId", 106, "description", "Summary creation during rendering phase", "estimate", 4, "rate", 125, "due", "07/02/2007"),
                new Dictionary("projectId", 102, "project", "Ext Grid: Summary Rows", "taskId", 107, "description", "Dynamic summary updates in editor grids", "estimate", 6, "rate", 125, "due", "07/05/2007"),
                new Dictionary("projectId", 102, "project", "Ext Grid: Summary Rows", "taskId", 108, "description", "Remote summary integration", "estimate", 4, "rate", 125, "due", "07/05/2007"),
                new Dictionary("projectId", 102, "project", "Ext Grid: Summary Rows", "taskId", 109, "description", "Summary renderers and calculators", "estimate", 4, "rate", 125, "due", "07/06/2007"),
                new Dictionary("projectId", 102, "project", "Ext Grid: Summary Rows", "taskId", 110, "description", "Integrate summaries with GroupingView", "estimate", 10, "rate", 125, "due", "07/11/2007"),
                new Dictionary("projectId", 102, "project", "Ext Grid: Summary Rows", "taskId", 111, "description", "Testing and debugging", "estimate", 8, "rate", 125, "due", "07/15/2007")
            };
        }
    }
}
